﻿using System;

namespace Program25
{
    internal class Program
    {
        static void Main(string[] args)
        {
            //GetSum(1,4,5,7....)求任意长度的和

            //GetScore("张三",学号,成绩1，成绩2,..)求任意门课程的总分
            //GetSum(8, 9);
            //Console.WriteLine(GetSum(8, 9,4,9,5));
            //Console.WriteLine(GetSum(8, 9, 4 ));

            //Test("我","100000级",100,88);
            //Console.WriteLine();
            GetScore("我",7999,96,100,60);
        }

        public static int GetSum(params int[] n)
        {
            var sum = 0;
            for (var i = 0; i < n.Length; i++)
            {
                sum += n[i];
            }

            return sum;
        }
        //params定义可变参数
        public static void Test(params Object[] objs)
        {
            Console.WriteLine(objs[0]);
            Console.WriteLine(objs[1]);
            Console.WriteLine(objs[2]);
            Console.WriteLine(objs[3]);
        }
        //可变参数放在所有形参的末尾
        public static void GetScore(string name, int id, params int[] scores)
        {
            
            var num = 0;
            for (var i = 0; i < scores.Length; i++)
            {
                num += scores[i];
            }
            Console.WriteLine("学号:{0}", id);
            Console.WriteLine("姓名：{0}", name);
            Console.WriteLine("总分：{0}", num);
            Console.WriteLine("平均分：{0}", num/scores.Length);
        }
    }
}
